<?php
class Zend_View_Helper_ProfileLink extends Zend_View_Helper_Abstract {
  public function profileLink() {
    $helperUrl = new Zend_View_Helper_Url ( );
    $auth = Zend_Auth::getInstance ();
    if ($auth->hasIdentity ()) {
      $username = $auth->getIdentity ()->user_forname . ' ' . strtoupper ( substr ( $auth->getIdentity ()->user_name, 0, 1 ) ) . '.';
      $logoutLink = $helperUrl->url ( array ('action' => 'logout', 'controller' => 'auth' ) );
      return 'Salut ' . $username . ' (<a href="' . $logoutLink . '">Logout</a>)';
    }
    $loginLink = $helperUrl->url ( array ('action' => 'login', 'controller' => 'auth' ) );
    return '<a href="' . $loginLink . '">Login</a>';
  }
}